<html>
<head><meta charset="utf-8"><title>secure rng · wg-secure-code · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/index.html">wg-secure-code</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html">secure rng</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="148298759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148298759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148298759">(Nov 25 2018 at 01:40)</a>:</h4>
<p>Is CSRNG in Rust too complicated? <a href="https://github.com/rust-random/rand/issues/648" target="_blank" title="https://github.com/rust-random/rand/issues/648">https://github.com/rust-random/rand/issues/648</a></p>



<a name="148298768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148298768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148298768">(Nov 25 2018 at 01:40)</a>:</h4>
<p>I have followed this project for years and not voiced an opinion</p>



<a name="148298775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148298775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148298775">(Nov 25 2018 at 01:41)</a>:</h4>
<p>but now I'm like... what I want is very simple, and what I am getting I no longer fully understand, and that's a bit frightening</p>



<a name="148298814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148298814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148298814">(Nov 25 2018 at 01:42)</a>:</h4>
<p>I say this all as I deal with a probably unrelated RNG debacle</p>



<a name="148298817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148298817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148298817">(Nov 25 2018 at 01:42)</a>:</h4>
<p>but I'm also asking myself how did aforementioned debacle even happen</p>



<a name="148298822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148298822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148298822">(Nov 25 2018 at 01:42)</a>:</h4>
<p>because ideally I would like to see it never ever happen again</p>



<a name="148298829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148298829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148298829">(Nov 25 2018 at 01:43)</a>:</h4>
<p>tl;dr: I'm not sure the <code>rand</code> API is what Rust cryptography needs</p>



<a name="148298876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148298876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148298876">(Nov 25 2018 at 01:45)</a>:</h4>
<p>conflating the needs of cryptographically secure random number generators and non cryptographically secure number generators, even behind marker traits, at least now seems like a bad idea to me</p>



<a name="148298921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148298921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148298921">(Nov 25 2018 at 01:46)</a>:</h4>
<p>it feels like an attempt to build abstractions where those abstractions aren't useful except to attackers</p>



<a name="148300013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148300013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148300013">(Nov 25 2018 at 02:29)</a>:</h4>
<p><span class="user-mention" data-user-id="132721">@Tony Arcieri</span> Is water wet?</p>



<a name="148300014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148300014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148300014">(Nov 25 2018 at 02:29)</a>:</h4>
<p>haha</p>



<a name="148300062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148300062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148300062">(Nov 25 2018 at 02:30)</a>:</h4>
<p><span class="user-mention" data-user-id="133214">@briansmith</span> should've used <em>ring</em>? <span class="emoji emoji-1f609" title="wink">:wink:</span></p>



<a name="148300066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148300066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148300066">(Nov 25 2018 at 02:30)</a>:</h4>
<p>/me having a bit of trouble with <em>ring</em> as a dependency but perhaps we can take that elsewhere</p>



<a name="148300075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148300075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148300075">(Nov 25 2018 at 02:31)</a>:</h4>
<p><span class="user-mention" data-user-id="132721">@Tony Arcieri</span> Sure, DM me.</p>



<a name="148308628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148308628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148308628">(Nov 25 2018 at 07:25)</a>:</h4>
<p>well I spent my night researching what is effectively a vulnerability (albeit in alpha quality software no one is relying on) and so far my conclusions are it is correctly generating random numbers on macOS, but not Linux</p>



<a name="148308629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148308629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148308629">(Nov 25 2018 at 07:25)</a>:</h4>
<p>I am continuing to investigate</p>



<a name="148308634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148308634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148308634">(Nov 25 2018 at 07:25)</a>:</h4>
<p>this is very unfortunate, though</p>



<a name="148308638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148308638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148308638">(Nov 25 2018 at 07:25)</a>:</h4>
<p>and I would like to find a way to prevent this class of bug from ever, ever happening again (at least without a panic)</p>



<a name="148312225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148312225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148312225">(Nov 25 2018 at 09:34)</a>:</h4>
<p>Are you able to provide any information on how usage of the <code>OsRng</code> (I presume it's that) can differ on Linux and macOS? First thing that comes to mind is using <code>fill</code> instead of <code>try_fill</code> and not correctly handling errors, but that seems unreasonable since <code>fill</code> handles things like waiting for an OS generator implicitly.</p>



<a name="148317092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148317092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148317092">(Nov 25 2018 at 12:30)</a>:</h4>
<p>There are other warts, such as the "give me random bytes" syscall being equivalent to reading from /dev/urandom as opposed to /dev/random, and you need the latter if you want to seed a cryptographically secure RNG in user-space. This is exacerbated by the fact that if your program running in a sandbox with no access to /dev/random, there is no way to get seed-quality entropy</p>



<a name="148325151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148325151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148325151">(Nov 25 2018 at 17:02)</a>:</h4>
<p>I'm using <code>fill_bytes</code></p>



<a name="148325163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148325163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148325163">(Nov 25 2018 at 17:03)</a>:</h4>
<p>the code in question is here: <a href="https://github.com/tendermint/signatory/blob/master/src/ed25519/seed.rs#L44" target="_blank" title="https://github.com/tendermint/signatory/blob/master/src/ed25519/seed.rs#L44">https://github.com/tendermint/signatory/blob/master/src/ed25519/seed.rs#L44</a></p>



<a name="148326130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148326130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148326130">(Nov 25 2018 at 17:37)</a>:</h4>
<p>more fun: <code>debug</code> builds on Linux seem ok. It's only <code>release</code> builds which are impacted.</p>



<a name="148326900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148326900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148326900">(Nov 25 2018 at 18:06)</a>:</h4>
<p>this is at least no longer looking like the <code>rand</code> crate's fault</p>



<a name="148327440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148327440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148327440">(Nov 25 2018 at 18:25)</a>:</h4>
<p><span class="user-mention" data-user-id="127617">@Shnatsel</span>  I actually just tried to test that, by having a binary executed in a firejail sandbox with <code>/dev/urandom/</code> and <code>/dev/random</code> blacklisted. When calling another library's generation function (<code>OsRng</code>) there were no errors reported, but when I tried to open <code>/dev/urandom/</code> with <code>std::File</code> it panicked on <code>PermissionDenied</code>. Seems a bit curious, but I'm sure there's something I've overlooked.</p>



<a name="148327656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148327656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148327656">(Nov 25 2018 at 18:34)</a>:</h4>
<p><code>getrandom</code> syscall I assume</p>



<a name="148327840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148327840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148327840">(Nov 25 2018 at 18:39)</a>:</h4>
<p>Yeah, the sandbox logs do say that getrandom() has been called</p>



<a name="148327994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148327994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148327994">(Nov 25 2018 at 18:44)</a>:</h4>
<p>FWIW it's the same behavior on both <code>debug</code> and <code>release</code>.</p>



<a name="148327997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148327997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148327997">(Nov 25 2018 at 18:45)</a>:</h4>
<p>Failing that it could also be  the <code>AT_RANDOM</code> aux value.</p>



<a name="148328186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148328186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148328186">(Nov 25 2018 at 18:50)</a>:</h4>
<p>IIUC that only provides a pointer to 16 bytes of random data? I'm generating 32.</p>



<a name="148328252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148328252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148328252">(Nov 25 2018 at 18:53)</a>:</h4>
<p>my issue ended up being an errant <code>debug_assert_eq!</code> which resulted in important code being compiled out of release builds. oops.</p>



<a name="148328260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148328260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148328260">(Nov 25 2018 at 18:53)</a>:</h4>
<p>so code under debug_assert_eq! had side-effects?</p>



<a name="148328297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148328297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148328297">(Nov 25 2018 at 18:54)</a>:</h4>
<p>Did it have noticeable results on the <code>Rng</code>s output?</p>



<a name="148328508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148328508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148328508">(Nov 25 2018 at 19:01)</a>:</h4>
<p><span class="user-mention" data-user-id="127617">@Shnatsel</span> this code is nothing but side effects, heh</p>



<a name="148328509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148328509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148328509">(Nov 25 2018 at 19:01)</a>:</h4>
<p>the RNG was a red herring, it was a bug in the encoding library (<code>subtle-encoding</code>)</p>



<a name="148328623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148328623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148328623">(Nov 25 2018 at 19:04)</a>:</h4>
<p>Ah, I see what you mean.</p>



<a name="148336467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148336467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148336467">(Nov 25 2018 at 23:16)</a>:</h4>
<p>I might look into rewriting the <code>Encoding</code> trait to use iterators, so there's no danger of exposing a zero-initialized buffer like what happened here... except for the part where you can't really "construct" an array out of an iterator yet, right? but it'd work for a <code>Vec</code> which does happen to be what was in use here</p>



<a name="148336470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148336470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148336470">(Nov 25 2018 at 23:16)</a>:</h4>
<p>I'm trying to keep the core API <code>no_std</code> friendly</p>



<a name="148336524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148336524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148336524">(Nov 25 2018 at 23:18)</a>:</h4>
<p><a href="https://github.com/rust-random/rand/pull/643#issuecomment-439114850" target="_blank" title="https://github.com/rust-random/rand/pull/643#issuecomment-439114850">https://github.com/rust-random/rand/pull/643#issuecomment-439114850</a></p>



<a name="148336528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148336528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148336528">(Nov 25 2018 at 23:18)</a>:</h4>
<p>something like <code>let buffer: [u8; 32] = mem::secure_randomized()</code> or thereabouts might be interesting</p>



<a name="148336533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148336533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148336533">(Nov 25 2018 at 23:19)</a>:</h4>
<p>possibly with an argument for whether or not to use a blocking or non-blocking CSRNG</p>



<a name="148340296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148340296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148340296">(Nov 26 2018 at 01:26)</a>:</h4>
<p><span class="user-mention" data-user-id="132721">@Tony Arcieri</span> Could you please link to the code that uses `debug_assert_eq!</p>



<a name="148340304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148340304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148340304">(Nov 26 2018 at 01:27)</a>:</h4>
<p>In particular, I am very curious about whether putting `debug_assert_eq!</p>



<a name="148340311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148340311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148340311">(Nov 26 2018 at 01:27)</a>:</h4>
<p>is effectively equivalent to MSVC's <code>__assume()</code> in release builds, which would be insane!</p>



<a name="148341742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341742">(Nov 26 2018 at 02:14)</a>:</h4>
<p>well you can probably guess, it was the side-effectful function which actually did the work, which in 20/20 hindsight is uhh, well rather embarrassing</p>



<a name="148341743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341743">(Nov 26 2018 at 02:14)</a>:</h4>
<p><span class="user-mention" data-user-id="133214">@briansmith</span> <a href="https://github.com/iqlusioninc/crates/pull/126" target="_blank" title="https://github.com/iqlusioninc/crates/pull/126">https://github.com/iqlusioninc/crates/pull/126</a></p>



<a name="148341747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341747">(Nov 26 2018 at 02:14)</a>:</h4>
<p>at least it's an interesting case study, although "secure rng" is a red herring at this point</p>



<a name="148341752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341752">(Nov 26 2018 at 02:14)</a>:</h4>
<p>my takeaways were, per <span class="user-mention" data-user-id="133214">@briansmith</span>'s suggestion, run tests with <code>--release</code></p>



<a name="148341761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341761">(Nov 26 2018 at 02:15)</a>:</h4>
<p>and it would be nice to replace the side effects with something more functional so the <code>Vec</code> in this case is never initialized in a bad (in this case all-zero) state</p>



<a name="148341807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341807">(Nov 26 2018 at 02:16)</a>:</h4>
<p>which I think is totally doable so long as I'm making a <code>Vec</code>... I want to try to try to change  the <code>no_std</code> parts of the <code>Encode</code> and <code>Decode</code> traits to operate on iterators rather than slices</p>



<a name="148341815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341815">(Nov 26 2018 at 02:17)</a>:</h4>
<p>that way when building a <code>Vec</code> I can just <code>collect()</code> the output, rather than making a <code>Vec</code> of zeroes to begin with</p>



<a name="148341984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341984">(Nov 26 2018 at 02:22)</a>:</h4>
<p>although back to the "secure rng" topic</p>



<a name="148341987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341987">(Nov 26 2018 at 02:22)</a>:</h4>
<p>the same thing would be nice for buffers initialized with random data</p>



<a name="148341988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341988">(Nov 26 2018 at 02:22)</a>:</h4>
<p>which is what I was suggesting above with something like <code>mem::secure_randomized()</code></p>



<a name="148341998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148341998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148341998">(Nov 26 2018 at 02:24)</a>:</h4>
<p>as opposed to initializing some buffer full of zeroes and calling <code>fill_bytes(&amp;mut buf)</code> or what have you to mutate full of randomness as a side effect</p>



<a name="148342138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148342138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148342138">(Nov 26 2018 at 02:28)</a>:</h4>
<p>given what just happened, suddenly I'm afraid of side effects</p>



<a name="148342519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148342519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148342519">(Nov 26 2018 at 02:41)</a>:</h4>
<p>the more I think about my <code>Encode</code> and <code>Decode</code> traits, the more I think they can be defined in terms of <code>ExactSizeIterator</code></p>



<a name="148345218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148345218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148345218">(Nov 26 2018 at 04:15)</a>:</h4>
<p><span class="user-mention" data-user-id="132721">@Tony Arcieri</span> I thought about that as well, and in fact the <code>rand</code> crate does have an API <code>() -&gt; T</code> that returns a T with a random value, for certain types of T.</p>



<a name="148345279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148345279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148345279">(Nov 26 2018 at 04:17)</a>:</h4>
<p>I remember I never added one because usually the type of the function would have to be <code>&lt;const N&gt;() -&gt; [u8; N]</code> and we don't have that capability in the type system yet.</p>



<a name="148371349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148371349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148371349">(Nov 26 2018 at 14:45)</a>:</h4>
<p>orly</p>



<a name="148389566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148389566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zach Reizner <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148389566">(Nov 26 2018 at 19:04)</a>:</h4>
<blockquote>
<p>There are other warts, such as the "give me random bytes" syscall being equivalent to reading from /dev/urandom as opposed to /dev/random, and you need the latter if you want to seed a cryptographically secure RNG in user-space. This is exacerbated by the fact that if your program running in a sandbox with no access to /dev/random, there is no way to get seed-quality entropy</p>
</blockquote>
<p><span class="user-mention" data-user-id="127617">@Shnatsel</span> I thought current wisdom around urandom vs random was that one should always use urandom to avoid blockking: <a href="https://www.2uo.de/myths-about-urandom" target="_blank" title="https://www.2uo.de/myths-about-urandom">https://www.2uo.de/myths-about-urandom</a></p>



<a name="148389819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148389819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148389819">(Nov 26 2018 at 19:07)</a>:</h4>
<p><code>/dev/random</code> and <code>/dev/urandom</code> are both kind of awful, lol. <code>getrandom()</code> is a lot nicer</p>



<a name="148389899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148389899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zach Reizner <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148389899">(Nov 26 2018 at 19:08)</a>:</h4>
<p><span class="user-mention" data-user-id="132721">@Tony Arcieri</span> because you don't need an fd or the open syscall or does it have some additional security properties?</p>



<a name="148389927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148389927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148389927">(Nov 26 2018 at 19:08)</a>:</h4>
<p>The former</p>



<a name="148389937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148389937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148389937">(Nov 26 2018 at 19:09)</a>:</h4>
<p>Check out section 3.5 of this paper: <a href="https://www.usenix.org/system/files/conference/hotos15/hotos15-paper-corrigan-gibbs.pdf" target="_blank" title="https://www.usenix.org/system/files/conference/hotos15/hotos15-paper-corrigan-gibbs.pdf">https://www.usenix.org/system/files/conference/hotos15/hotos15-paper-corrigan-gibbs.pdf</a></p>



<a name="148389939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148389939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148389939">(Nov 26 2018 at 19:09)</a>:</h4>
<p>"always use <code>/dev/urandom</code>" covers most bases. then I see "but select on <code>/dev/random</code> to ensure it's readable before you access <code>/dev/urandom</code> and so forth"</p>



<a name="148389942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148389942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148389942">(Nov 26 2018 at 19:09)</a>:</h4>
<p>It's one of my favorites</p>



<a name="148389956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148389956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148389956">(Nov 26 2018 at 19:09)</a>:</h4>
<p>Oh and also blocking, yeah</p>



<a name="148390057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390057">(Nov 26 2018 at 19:10)</a>:</h4>
<p><span class="user-mention" data-user-id="132723">@Zach Reizner</span> it both eliminates the need to juggle a file descriptor and provides flags with precise semantics so you don't need to resort to cargo cult incantations</p>



<a name="148390083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zach Reizner <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390083">(Nov 26 2018 at 19:10)</a>:</h4>
<p>Oh, and if an attacker can force a host to use <code>/dev/random</code> many times, they can trigger a DoS to everything else that wants to use <code>/dev/random</code> when the entropy counter goes low.</p>



<a name="148390104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390104">(Nov 26 2018 at 19:11)</a>:</h4>
<p>I've seen that wedge a KDC in practice <span class="emoji emoji-1f629" title="weary">:weary:</span></p>



<a name="148390110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390110">(Nov 26 2018 at 19:11)</a>:</h4>
<p>It's worse than a DoS since many utilities which provide randomness just assume that <code>open("/dev/urandom")</code> always succeeds</p>



<a name="148390128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390128">(Nov 26 2018 at 19:11)</a>:</h4>
<p>And when it fails, they end up reading bytes from a bad FD, getting no actual randomness</p>



<a name="148390144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390144">(Nov 26 2018 at 19:11)</a>:</h4>
<p>It's basically as bad as accidentally reading from <code>/dev/zero</code></p>



<a name="148390147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zach Reizner <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390147">(Nov 26 2018 at 19:11)</a>:</h4>
<p>Wow, that's some pretty bad programming. <span class="emoji emoji-2639" title="sad">:sad:</span></p>



<a name="148390155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390155">(Nov 26 2018 at 19:11)</a>:</h4>
<p>Agreed</p>



<a name="148390164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390164">(Nov 26 2018 at 19:12)</a>:</h4>
<p>But such is the world we live in :/</p>



<a name="148390206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390206">(Nov 26 2018 at 19:12)</a>:</h4>
<p><code>ln -fs /dev/zero /dev/urandom</code> <span class="emoji emoji-1f608" title="smiling devil">:smiling_devil:</span></p>



<a name="148390210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148390210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zach Reizner <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148390210">(Nov 26 2018 at 19:12)</a>:</h4>
<p>Agreed</p>



<a name="148400141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148400141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148400141">(Nov 26 2018 at 21:40)</a>:</h4>
<p><code>/dev/random</code>'s bizzare notions of entropy have taken down IRS systems before, leading to at least two <a href="http://healthcare.gov" target="_blank" title="http://healthcare.gov">healthcare.gov</a> outages :-(</p>



<a name="148404777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148404777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148404777">(Nov 26 2018 at 22:48)</a>:</h4>
<p>Last time I checked /dev/random vs /dev/urandom vs hardware RNG debacle was still debated, with each side having valid points <span class="emoji emoji-1f615" title="oh no">:oh_no:</span></p>



<a name="148404980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148404980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148404980">(Nov 26 2018 at 22:52)</a>:</h4>
<p>The link that <span class="user-mention" data-user-id="132723">@Zach Reizner</span> posted earlier (<a href="https://www.2uo.de/myths-about-urandom" target="_blank" title="https://www.2uo.de/myths-about-urandom">https://www.2uo.de/myths-about-urandom</a>) sums it up pretty nicely. TLDR: Once everything is properly initialized, <code>/dev/urandom</code> is just as secure as <code>/dev/random</code>.</p>



<a name="148404991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148404991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148404991">(Nov 26 2018 at 22:52)</a>:</h4>
<p>The problem is that, before things are initialized, their behavior is different in confusing and dangerous ways.</p>



<a name="148405693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148405693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148405693">(Nov 26 2018 at 23:04)</a>:</h4>
<p>Which <code>getrandom</code> addresses. The re-seeding behavior of <code>/dev/random</code> is the pointless part.</p>



<a name="148405877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148405877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148405877">(Nov 26 2018 at 23:07)</a>:</h4>
<p>Right.</p>



<a name="148405943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148405943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148405943">(Nov 26 2018 at 23:08)</a>:</h4>
<p>(well, pointless under the assumption that the system is secure; in practice, it's possibly useful as a backstop against attacks that manage to learn some of the internal state of the PRNG)</p>



<a name="148406151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148406151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148406151">(Nov 26 2018 at 23:12)</a>:</h4>
<p>Err, sorry I shouldn't have said re-seeding. Both urandom and random reseed, it's the blocking on "low entropy" that's nonsense.</p>



<a name="148406293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148406293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148406293">(Nov 26 2018 at 23:15)</a>:</h4>
<p>Ah, right. The idea that, once properly initialized, you can dip below the entropy threshold <em>and detect this with code</em> is unfounded.</p>



<a name="148406299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148406299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148406299">(Nov 26 2018 at 23:15)</a>:</h4>
<p>The entire point of a backstop against insufficient entropy is that we have no formal characterization of how that might happen, which is why we believe these systems to be theoretically sound in the first place.</p>



<a name="148407190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148407190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148407190">(Nov 26 2018 at 23:33)</a>:</h4>
<p>My favorite problem with /dev/urandom and /dev/random was in some code that closed all open file descriptors manually at a certain point during startup (looped from fd 0 until it got EBADFD from close()), not expecting any libraries to have opened files. Then it opened another file that reused that file descriptor, and the PRNG started reading from that file and nobody noticed for a LONG time.</p>



<a name="148407248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148407248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148407248">(Nov 26 2018 at 23:34)</a>:</h4>
<p>Oh wow that's juicy.</p>



<a name="148407268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148407268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148407268">(Nov 26 2018 at 23:35)</a>:</h4>
<p>Python <code>fstat</code>s the file descriptor and checks that <code>(ino, dev)</code> hasn't changed because of this garbage.</p>



<a name="148407273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148407273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148407273">(Nov 26 2018 at 23:35)</a>:</h4>
<p>What a beautiful hack. How sad that that's necessary.</p>



<a name="148407344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148407344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148407344">(Nov 26 2018 at 23:37)</a>:</h4>
<p>Alex, I'm always impressed with how the Python stuff adds these kinds of workarounds. I myself would love to turn off the fallback to /dev/urandom in my code to avoid the situation completely.</p>



<a name="148407513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148407513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148407513">(Nov 26 2018 at 23:40)</a>:</h4>
<p>I presume that once the last version of Linux w/o the syscall isn't supported by Python, that'll be a viable option?</p>



<a name="148407543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148407543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148407543">(Nov 26 2018 at 23:41)</a>:</h4>
<p>I want to kill non-<code>getrandom</code> paths for pyca/cryptography. I should look at the metrics and figure out how impossible that is.</p>



<a name="148740704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148740704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148740704">(Nov 28 2018 at 20:27)</a>:</h4>
<p>just use RDRAND [img:trollface]</p>



<a name="148740746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148740746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148740746">(Nov 28 2018 at 20:28)</a>:</h4>
<p>(literally what I'm doing in SGX, but in for a penny, in for a pound there)</p>



<a name="148740755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148740755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148740755">(Nov 28 2018 at 20:28)</a>:</h4>
<p>Oh I think I spot your problem:</p>



<a name="148740759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148740759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148740759">(Nov 28 2018 at 20:28)</a>:</h4>
<p>You're using SGX.</p>



<a name="148740761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148740761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148740761">(Nov 28 2018 at 20:28)</a>:</h4>
<p>kinda the way I feel about, you know, the CPU in general, but using RDRAND from regular ol' Linux userspace is bad for virtue signaling</p>



<a name="148740763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148740763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148740763">(Nov 28 2018 at 20:28)</a>:</h4>
<p>haha</p>



<a name="148740767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148740767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148740767">(Nov 28 2018 at 20:28)</a>:</h4>
<p>at least I'm using SGX to talk to HSMs</p>



<a name="148740772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/148740772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#148740772">(Nov 28 2018 at 20:28)</a>:</h4>
<p>fair</p>



<a name="151539427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151539427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151539427">(Dec 12 2018 at 17:09)</a>:</h4>
<p>is anyone interested in working on an RFC for stabilizing an "OS rng" lang item and associated <code>std</code>/<code>core</code> API? <a href="https://github.com/rust-random/rand/issues/648" target="_blank" title="https://github.com/rust-random/rand/issues/648">https://github.com/rust-random/rand/issues/648</a></p>



<a name="151566611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151566611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151566611">(Dec 12 2018 at 21:55)</a>:</h4>
<p>Hmm, why a lang item vs. just an in-tree implementation?</p>



<a name="151567323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567323">(Dec 12 2018 at 22:07)</a>:</h4>
<p>Can you summarize the (long) discussion on that issue? Was the consensus that we should move to <code>std</code>/<code>core</code>?</p>



<a name="151567834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567834">(Dec 12 2018 at 22:16)</a>:</h4>
<p><span class="user-mention" data-user-id="130046">@Alex Gaynor</span> so if you're on an RTOS or doing bare metal programming on an embedded device, you can leverage the available platform RNG</p>



<a name="151567849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567849">(Dec 12 2018 at 22:17)</a>:</h4>
<p>Why does that require it to be a lang item?</p>



<a name="151567856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567856">(Dec 12 2018 at 22:17)</a>:</h4>
<p>or when I was doing, say, Thales CodeSafe, talk to the SEE/TEE/TPM via their proprietary messaging protocol (wrapped up in SEElib) and get random numbers that way</p>



<a name="151567860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567860">(Dec 12 2018 at 22:17)</a>:</h4>
<p>Hmm, so that'd be applicable to a <code>core</code> solution. I think my (weakly held!) opinion is that we ought to start with a simple <code>std</code> API for tier-1 platforms.</p>



<a name="151567864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567864">(Dec 12 2018 at 22:17)</a>:</h4>
<p><span class="user-mention" data-user-id="132362">@Joshua Liebow-Feeser</span> well first, because the platform abstraction is already in-tree</p>



<a name="151567873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567873">(Dec 12 2018 at 22:17)</a>:</h4>
<p>and there is no mechanism by which you can provide an alternative implementation in an embedded context</p>



<a name="151567886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567886">(Dec 12 2018 at 22:17)</a>:</h4>
<p>Yeah, I agree with Alex. There's enough complexity to get right even for that.</p>



<a name="151567888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567888">(Dec 12 2018 at 22:18)</a>:</h4>
<p>even if it's, say, Thales providing a more-or-less <code>getrandom()</code>-style API</p>



<a name="151567954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567954">(Dec 12 2018 at 22:18)</a>:</h4>
<p>E.g., what's the blocking semantics? On Linux, what do we do if getrandom isn't available? What do we do if a call fails? What do we do if getrandom isn't available and /dev/urandom can't be opened because we're out of FDs? etc.</p>



<a name="151567965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567965">(Dec 12 2018 at 22:18)</a>:</h4>
<p><code>getrandom()</code> is parameterized around the blocking semantics</p>



<a name="151567979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567979">(Dec 12 2018 at 22:19)</a>:</h4>
<p>I know; I'm just saying that we have to nail all of those details down</p>



<a name="151567988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567988">(Dec 12 2018 at 22:19)</a>:</h4>
<p>if it doesn't exist, you need to "polyfill"</p>



<a name="151567994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567994">(Dec 12 2018 at 22:19)</a>:</h4>
<p>which is possible with <code>/dev/random</code> and <code>/dev/urandom</code> on Linux</p>



<a name="151567996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567996">(Dec 12 2018 at 22:19)</a>:</h4>
<p>My ideal API is one which a) blocks completely and, b) aborts the process if there's ever an error.</p>



<a name="151567998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151567998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151567998">(Dec 12 2018 at 22:19)</a>:</h4>
<p>in a somewhat hackish manner</p>



<a name="151568055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151568055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151568055">(Dec 12 2018 at 22:20)</a>:</h4>
<p>I know. I'm just saying that it's complex enough that it's probably worth its own RFC. We have to do the same thing on all of the tier-1 platforms.</p>



<a name="151568060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151568060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151568060">(Dec 12 2018 at 22:20)</a>:</h4>
<p>select-for-read on <code>/dev/random</code> will block until the kernel entropy pool has been seeded (I think)</p>



<a name="151568078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151568078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151568078">(Dec 12 2018 at 22:20)</a>:</h4>
<blockquote>
<p>select-for-read on <code>/dev/random</code> will block until the kernel entropy pool has been seeded (I think)</p>
</blockquote>
<p>I believe that's correct, although I'd need to double-check.</p>



<a name="151568087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151568087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151568087">(Dec 12 2018 at 22:20)</a>:</h4>
<p>there's a couple things going on here</p>



<a name="151568093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151568093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151568093">(Dec 12 2018 at 22:20)</a>:</h4>
<p>one is a stable <code>std</code> or <code>core</code> API</p>



<a name="151568097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151568097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151568097">(Dec 12 2018 at 22:20)</a>:</h4>
<p>another is a lang item</p>



<a name="151568103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151568103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151568103">(Dec 12 2018 at 22:20)</a>:</h4>
<p>I'd like both</p>



<a name="151568115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151568115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151568115">(Dec 12 2018 at 22:21)</a>:</h4>
<p>I agree. However, I think Alex's point is that we can do the former first and then add a lang item later.</p>



<a name="151568116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/151568116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#151568116">(Dec 12 2018 at 22:21)</a>:</h4>
<p>but I'd be interested in working on either</p>



<a name="152333064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/152333064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#152333064">(Dec 21 2018 at 14:16)</a>:</h4>
<p><a href="https://github.com/dhardy/rfcs/blob/system-random/text/0000-system-random.md" target="_blank" title="https://github.com/dhardy/rfcs/blob/system-random/text/0000-system-random.md">https://github.com/dhardy/rfcs/blob/system-random/text/0000-system-random.md</a></p>



<a name="157073384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157073384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157073384">(Jan 29 2019 at 01:42)</a>:</h4>
<p>Has this been turned into a PR on the RFCs repo yet?</p>



<a name="157073795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157073795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157073795">(Jan 29 2019 at 01:52)</a>:</h4>
<p>I don't think so... this is the last update on it I see <a href="https://github.com/rust-random/rand/issues/648#issuecomment-451286240" target="_blank" title="https://github.com/rust-random/rand/issues/648#issuecomment-451286240">https://github.com/rust-random/rand/issues/648#issuecomment-451286240</a></p>



<a name="157073799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157073799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Liebow-Feeser <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157073799">(Jan 29 2019 at 01:52)</a>:</h4>
<p>mmmmk</p>



<a name="157233180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157233180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gerardo Di Giacomo <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157233180">(Jan 30 2019 at 23:37)</a>:</h4>
<p>ThreadRng is considered, by documentation,  a safe CSPRNG, however I've always been wary of user-space RNGs (and my understanding is that threadrng is user-space). is it actually safe to use or it's preferable/better/mandatory to use OsRng ?</p>



<a name="157235314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235314">(Jan 31 2019 at 00:17)</a>:</h4>
<p>I share these opinions. There is work on a <code>getranndom</code> crate which does what I consider the right thing, which is "get randomness from the platform" (i.e. kernel) <a href="https://github.com/rust-random/getrandom" target="_blank" title="https://github.com/rust-random/getrandom">https://github.com/rust-random/getrandom</a></p>



<a name="157235326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235326">(Jan 31 2019 at 00:17)</a>:</h4>
<p>whenever they release it I will switch over (from <code>rand_os</code>)</p>



<a name="157235328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235328">(Jan 31 2019 at 00:17)</a>:</h4>
<p>my main concern has been <code>JitterRng</code></p>



<a name="157235333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235333">(Jan 31 2019 at 00:17)</a>:</h4>
<p>which... ugh</p>



<a name="157235395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235395">(Jan 31 2019 at 00:18)</a>:</h4>
<p>maybe a year ago I suggested Randen</p>



<a name="157235406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235406">(Jan 31 2019 at 00:19)</a>:</h4>
<p>and was told "it's too new to trust!" sure fine</p>



<a name="157235453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235453">(Jan 31 2019 at 00:19)</a>:</h4>
<p>but then all of my stuff started breaking because of <code>rand</code> crate changes which manifested as <code>JitterRng</code> breakages</p>



<a name="157235456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235456">(Jan 31 2019 at 00:19)</a>:</h4>
<p>and I'm like "what the hell is this"</p>



<a name="157235536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235536">(Jan 31 2019 at 00:20)</a>:</h4>
<p>I spent a few days learning about it and saw it was a Havaged-alike "CryptoRng" which creates "secure randomnness" by doing a bunch of ad hoc branching on attacker-influenceable values</p>



<a name="157235548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235548">(Jan 31 2019 at 00:21)</a>:</h4>
<p>and then I started reading papers and concluded that entire approach as no basis in cryptography research</p>



<a name="157235555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235555">(Jan 31 2019 at 00:21)</a>:</h4>
<p>people call it "TRNG" but that's... not what TRNG means</p>



<a name="157235557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235557">(Jan 31 2019 at 00:21)</a>:</h4>
<p>TRNGs are hardware devices</p>



<a name="157235624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157235624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157235624">(Jan 31 2019 at 00:22)</a>:</h4>
<p>so anyway tl;dr: Randen is a much better candidate for a <code>CryptoRng</code> than <code>JitterRng</code></p>



<a name="157272177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157272177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157272177">(Jan 31 2019 at 13:43)</a>:</h4>
<p>Randen has official Rust bindings too, wow. <br>
The dependency on hardware-accelerated AES for performance is not great though. Not all x86_64 CPUs have it, which means it cannot be used as a default without runtime RNG selection, and you need some kind of fallback anyway.</p>



<a name="157294578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157294578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157294578">(Jan 31 2019 at 18:45)</a>:</h4>
<p>yes the joys of AES-NI detection and fallback</p>



<a name="157302515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157302515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gerardo Di Giacomo <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157302515">(Jan 31 2019 at 20:13)</a>:</h4>
<blockquote>
<p>so anyway tl;dr: Randen is a much better candidate for a <code>CryptoRng</code> than <code>JitterRng</code></p>
</blockquote>
<p>thanks for the comments. but what about threadrng? :D</p>



<a name="157302546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157302546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gerardo Di Giacomo <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157302546">(Jan 31 2019 at 20:13)</a>:</h4>
<p>I've been switching to OsRng</p>



<a name="157302680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157302680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gerardo Di Giacomo <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157302680">(Jan 31 2019 at 20:15)</a>:</h4>
<p>but I (security) have to debate with engineering as the documentation says that threadrng is safe to use</p>



<a name="157363870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/157363870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#157363870">(Feb 01 2019 at 16:12)</a>:</h4>
<p><span class="user-mention" data-user-id="144034">@Gerardo Di Giacomo</span> well I think ideally it'd be safe to use, but isn't quite yet, IMO. there's a lot that's in flux right now</p>



<a name="166147408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/secure%20rng/near/166147408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/secure.20rng.html#166147408">(May 21 2019 at 07:01)</a>:</h4>
<p><a href="https://github.com/rust-random/getrandom/issues/21" target="_blank" title="https://github.com/rust-random/getrandom/issues/21">https://github.com/rust-random/getrandom/issues/21</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>